define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'send/log/index',
        add_url: 'send/log/add',
        edit_url: 'send/log/edit',
        delete_url: 'send/log/delete',
        export_url: 'send/log/export',
        modify_url: 'send/log/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar:['refresh','export'],
                cols: [[
                    //{type: 'checkbox'},
                    //{field: 'id', title: 'ID',search: false},
                    //{field: 'noid', title: '角色ID',search: false},
                    //{field: 'wupid', title: '物品ID',search: false},
                    {field: 'title', title: '标题'},
                    {field: 'info', title: '内容',search: false},
                    {field: 'account', title: '账号'},
                    {field: 'gamename', title: '角色'},
                    {field: 'num', title: '数量',search: false},
                    {field: 'hztype', title: '红字',search: false, selectList: {0: '<a style="color:#adadad">无红字</a>', 1: '<a style="color:#ff2222">体力</a>', 2: '<a style="color:#16b777">精神</a>', 3: '<a style="color:#ab7e0b">力量</a>', 4: '<a style="color:#1e9fff">智力</a>'}},
                    {field: 'hznum', title: '红字值',search: false},
                    {field: 'gold', title: '金币',search: false},
                    {field: 'fz', title: '封装',search: false, selectList: {1: '<a style="color:green">是</a>', 0: '<a style="color:red">否</a>'}},
                    {field: 'dz', title: '锻造',search: false},
                    {field: 'qh', title: '强化',search: false},
                    {field: 'addtime', title: '时间',search: false,templet:'<div><a>{{dateFormat(d.addtime)}}</a></div>'},
                    {field: 'status', title: '状态', selectList: {1: '<a style="color:green">成功</a>', 0: '<a style="color:red">失败</a>', 2: '<a style="color:#c99100">补发</a>'}, search: false},
                    {
                        width: 250,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '补发',
                                url: 'send/log/sendbf',
                                method: 'request',
                                auth: 'stock',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                                extend: 'data-full="true"',
                            }],
                          ]
                    }
                ]],
                done: function(res, curr, count) {
                    var tableData = res.data;
                    for (var i = 0; i < tableData.length; i++) {
                        var status = tableData[i].status;
                        if (status != 0) {
                            // 隐藏操作列
                            $('.layui-table-box tbody tr:eq(' + i + ')').find('.layui-table-col-special').hide();
                        }
                    }
                }
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});